const mongoose = require('../conn').mongoose

const db = mongoose.connection
db.on('error', err => {
    console.log('mongodb err', err)
})
db.on('open', ()=>{
    console.log('已连接')
})

const categorySchema = new mongoose.Schema({
    name: {
        type: String,
        index: true,
        unique: true
    },
    description: String,
    fname: String,
    createdAt: {
        type: Date,
        default: Date.now
    }
})

const Category = mongoose.model('Category', categorySchema)

module.exports = Category;
